package com.yifeng.repo.micro.service.client.configure;

import feign.Logger;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * Created by daibing on 2022/8/6.
 */
@ConfigurationProperties(prefix = "yfcloud.micro.service.client")
public class MicroServiceClientProperties {

    private boolean enabled;

    /**
     * 打印请求日志
     * 1. NONE: 不记录任何信息
     * 2. BASIE: 仅记录请求方法，URL以及响应状态码和执行时间
     * 3. HEADERS: 在BASIC的基础上，额外记录了请求和响应的头信息
     * 4. FULL：记录所有请求和响应的明细，包括头信息、请求体、元数据。
     */
    private String feignLogLevel = Logger.Level.BASIC.name();

    /**
     * Request.Options 设置请求超时时间
     */
    private long connectTimeout = 2000;
    private long readTimeout = 60 * 1000;

    /**
     * Retryer 设置请求重试
     */
    private boolean retry = false;
    private int retryMaxAttempts = 3;
    private long retryPeriod = 100;
    private long retryMaxPeriod = 1000;

    /**
     * httpclient
     */
    private boolean enableHttpClient;
    private int maxConnections = 200;
    private int maxConnectionsPerRoute = 50;

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public String getFeignLogLevel() {
        return feignLogLevel;
    }

    public void setFeignLogLevel(String feignLogLevel) {
        this.feignLogLevel = feignLogLevel;
    }

    public long getConnectTimeout() {
        return connectTimeout;
    }

    public void setConnectTimeout(long connectTimeout) {
        this.connectTimeout = connectTimeout;
    }

    public long getReadTimeout() {
        return readTimeout;
    }

    public void setReadTimeout(long readTimeout) {
        this.readTimeout = readTimeout;
    }

    public boolean isRetry() {
        return retry;
    }

    public void setRetry(boolean retry) {
        this.retry = retry;
    }

    public int getRetryMaxAttempts() {
        return retryMaxAttempts;
    }

    public void setRetryMaxAttempts(int retryMaxAttempts) {
        this.retryMaxAttempts = retryMaxAttempts;
    }

    public long getRetryPeriod() {
        return retryPeriod;
    }

    public void setRetryPeriod(long retryPeriod) {
        this.retryPeriod = retryPeriod;
    }

    public long getRetryMaxPeriod() {
        return retryMaxPeriod;
    }

    public void setRetryMaxPeriod(long retryMaxPeriod) {
        this.retryMaxPeriod = retryMaxPeriod;
    }

    public boolean isEnableHttpClient() {
        return enableHttpClient;
    }

    public void setEnableHttpClient(boolean enableHttpClient) {
        this.enableHttpClient = enableHttpClient;
    }

    public int getMaxConnections() {
        return maxConnections;
    }

    public void setMaxConnections(int maxConnections) {
        this.maxConnections = maxConnections;
    }

    public int getMaxConnectionsPerRoute() {
        return maxConnectionsPerRoute;
    }

    public void setMaxConnectionsPerRoute(int maxConnectionsPerRoute) {
        this.maxConnectionsPerRoute = maxConnectionsPerRoute;
    }
}
